package vip.xiaonuo.modular.file.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.file.MultipartFileParam;
import vip.xiaonuo.modular.file.util.FileChunkUtils;

import java.io.IOException;

/**
 * FileChunkController
 *
 * @author JackLee
 * 2022/7/29 10:38
 */
@RestController
public class FileChunkController {

    @PostMapping("/file/upload")
    public ResponseData upload(MultipartFileParam param) throws IOException {
        return new SuccessResponseData(FileChunkUtils.uploadByMappedByteBuffer(param));
    }


    @PostMapping("/file/upload/chunk/check")
    public ResponseData checkUploadChunk(MultipartFileParam param) throws IOException {
        return new SuccessResponseData(FileChunkUtils.checkUploadStatus(param));
    }
}
